package com.ruoyi.common.exception.global;

import lombok.Getter;

/**
 * @author cc
 * @date: 2024/12/27 10:21
 * @Description:
 */
@Getter
public enum BusinessErrorEnums implements IError {
    SYSTEM_INTERNAL_ERROR(100000, "服务器内部错误"),
    // 未授权
    UNAUTHORIZED(100001, "未授权"),
    PAY_UNAUTHORIZED(100002, "支付未授权"),
    INVALID_PARAMETER(100003, "参数错误"),
    INVALID_CONVERT(100004, "类型转化错误,请输入正确参数"),
    INVALID_HTTP_METHOD(100005, "错误的调用类型"),


    // 业务异常
    USER_NOT_EXIST(200001, "用户不存在"),
    // 不在区域范围内
    NOT_IN_AREA(200002, "不在区域范围内"),
    // 接到乘客的经纬度参数异常
    PICK_UP_LAT_LNG_ERROR(200003, "接到乘客的经纬度参数异常"),
    // 租户id不能为空
    ;

    final Integer errorCode;
    final String errorMessage;

    BusinessErrorEnums(Integer errorCode, String errorMessage) {
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
    }

    BusinessErrorEnums(String errorMessage) {
        this.errorCode = 100000;
        this.errorMessage = errorMessage;
    }

    // 通过errorCode 获取枚举
    public static BusinessErrorEnums getByErrorCode(Integer errorCode) {
        for (BusinessErrorEnums errorEnums : values()) {
            if (errorEnums.getErrorCode().equals(errorCode)) {
                return errorEnums;
            }
        }
        return null;
    }

    public String getNamespace() {
        return "";
    }

}
